package com.gs.service.stayregister;

import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gs.dao.StayRegisterDao;
import com.gs.pojo.StayRegister;
import com.gs.utils.Page;

@Service
public class StayRegisterServiceImpl implements StayRegisterService{

	@Resource
	private StayRegisterDao stayRegisterDao;
	@Override
	public List<StayRegister> selectAll() {
		return stayRegisterDao.selectAll();
	}
	@Override
	public List<StayRegister> selectShuJuTongJi(Timestamp min, Timestamp max) {
		return stayRegisterDao.selectShuJuTongJi(min, max);
	}
	@Override
	public int updateRemind(int id, int remind) {
		return stayRegisterDao.updateRemind(id, remind);
	}
	@Override
	public Page<StayRegister> pageFuzzyselectOne(int receiveTargeTypeID, int isBillID, String roomNumber, Page<StayRegister> vo) {
		int start =0;
		if (vo.getCurrentPage()>1) {
			start = (vo.getCurrentPage()-1)*vo.getPageSize(); //页码计算
		}
		List<StayRegister> list = stayRegisterDao.pageFuzzyselectOne(receiveTargeTypeID, isBillID, roomNumber, start, vo.getPageSize());
		vo.setResult(list); //分页查询的结果保存在list里
		int count = stayRegisterDao.countFuzzyselectOne(receiveTargeTypeID, isBillID, roomNumber);
		vo.setTotal(count);
		return vo;
	}
	//根据 团队id来查询 总费用
	public	List<StayRegister> selectFormTeamId(int receiveTargetID,int isBillID){
		return stayRegisterDao.selectFormTeamId(receiveTargetID, isBillID);
	}
	//根据结账状态ID查询团队小伙伴是否结账
	public List<StayRegister> selectFormTeamIdTwo(int isBillID){
		return stayRegisterDao.selectFormTeamIdTwo(isBillID);
	}
	@Override
	public Page<StayRegister> pageFuzzyselectTwo(int receiveTargetID, int isBillID, String roomNumber, Page<StayRegister> vo) {
		int start=0;
		if (vo.getCurrentPage()>1) {
			start=(vo.getCurrentPage()-1)*vo.getPageSize();
		}
		List<StayRegister> list=stayRegisterDao.pageFuzzyselectTwo(receiveTargetID, isBillID, roomNumber,start, vo.getPageSize());
		vo.setResult(list);
		int count=stayRegisterDao.countFuzzyselectTwo(receiveTargetID, isBillID, roomNumber);
		vo.setTotal(count);
		return vo;
	}
	@Override
	public Page<StayRegister> pageFuzzyselectThree(int isBillID, String roomNumber, Page<StayRegister> vo) {
		int start=0;
		if (vo.getCurrentPage()>1) {
			start=(vo.getCurrentPage()-1)*vo.getPageSize();
		}
		List<StayRegister> list=stayRegisterDao.pageFuzzyselectThree( isBillID, roomNumber,start, vo.getPageSize());
		vo.setResult(list);
		int count=stayRegisterDao.countFuzzyselectThree(isBillID, roomNumber);
		vo.setTotal(count);
		return vo;
	}
	public int insertAll(StayRegister stayRegister) {
		return stayRegisterDao.insertAll(stayRegister);
	}

	public int updateStayRegisterPredetermineID(Integer predetermineID, Integer id) {
		return stayRegisterDao.updateStayRegisterPredetermineID(predetermineID,id);
	}

	public int insertDeposit(StayRegister stayRegister) {
		return stayRegisterDao.insertDeposit(stayRegister);
	}
	@Override
	public int insertStayregisterdetails(Integer stayRegisterID, Integer passengerID) {
		return stayRegisterDao.insertStayregisterdetails(stayRegisterID, passengerID);
	}
	@Override
	public int updateChangRoom(StayRegister stayRegister) {
		return stayRegisterDao.updateChangRoom(stayRegister);
	}
	@Override
	public List<StayRegister> selectChangRoom(int id) {
		return stayRegisterDao.selectChangRoom(id);
	}
	@Override
	public List<StayRegister> selectMoney(int id) {
		return stayRegisterDao.selectMoney(id);
	}
	@Override
	public List<StayRegister> selectDepositById(Integer id) {
		return stayRegisterDao.selectDepositById(id) ;
	}
	@Override
	public Page<StayRegister> pageConsumption(Integer consumptionStayRegisterID, Page<StayRegister> vo) {
		int start=0;
		if (vo.getCurrentPage()>1) {
			start=(vo.getCurrentPage()-1)*vo.getPageSize();
		}
		List<StayRegister> list=stayRegisterDao.pageConsumption(consumptionStayRegisterID, start, vo.getPageSize());
		vo.setResult(list);
		int count=stayRegisterDao.countConsumption(consumptionStayRegisterID);
		vo.setTotal(count);
		return vo;
	}

	@Override
	public int deleteConsumption(Integer id) {
		return stayRegisterDao.deleteConsumption(id);
	}
	@Override
	public int insertConsumptiondetails(StayRegister stayRegister) {
		return stayRegisterDao.insertConsumptiondetails(stayRegister);
	}

}
